<!DOCTYPE html>
<html>
<head>
<title>创建卡券</title>
<include file="Public/head"/>
<link href="__CSS__/card_control.css" rel="stylesheet">
<link href="__CSS__/section_card_notification.css" rel="stylesheet">
<!--<link href="<?php echo $this->RlStaticResource;?>plugins/css/dropzone/basic.css" rel="stylesheet">
<link href="<?php echo $this->RlStaticResource;?>plugins/css/dropzone/dropzone.css" rel="stylesheet"><link href="/Public/Admin/css/default_color.css" rel="stylesheet">-->
<link href="__CSS__/datepicker3.css" rel="stylesheet">

<style type="text/css">
#dataselect .input-group-btn,#ym-select .input-group-btn{width: 12%;}
#dataselect .input-sm ,#ym-select .input-sm{ border-radius: 7px; height:40px;}
#dataselect .btn-primary ,#ym-select .btn-primary{ margin-left: 20px; border-radius:4px;margin-bottom: 0px;}
#dataselect .input-group-addon,#ym-select .input-group-addon{border-radius: 7px;}
.ibox-content{ min-height:800px;}
.dropz .dz-image-preview{display:none;}
.uploadify-button {
    background-color: #44B549;
    color: #fff;
	text-align:center;
    font-weight:bold;
}
</style>
<!-- Data picker -->
<script src="__JS__/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="/Public/static/uploadify/jquery.uploadify.min.js"></script>
</head>
<body>
	<div id="wrapper">
	<include file="Public/leftmenu"/>
		<div id="page-wrapper" class="gray-bg">
			<include file="Public/top"/>
			<div class="row wrapper border-bottom white-bg page-heading">
                <div class="col-lg-10">
                    <h2>优惠卡券</h2>
                    <ol class="breadcrumb">
                        <li><a>Coupon</a></li>
                        <li><a href='?s=Coupon/index'>卡券管理</a></li>
                        <li class="active"><strong>创建卡券</strong></li>
                    </ol>
                </div>
                <div class="col-lg-2"></div>
			</div>
			<div class="wrapper wrapper-content animated fadeIn">
				<div class="row" id="wrapper-content-list">
					<div class="col-lg-12">
						<div class="ibox float-e-margins">
							<div class="ibox-title">	
								<div class="alert alert-warning" style="font-size: 16px;"> 温馨提示：请仔细填写内容项</div>
							</div>
							<div class="ibox-content">
								<div class="group">

	<form id="form1" onsubmit="return cc();" class="media_edit"  method="POST" action="{:U()}" > 
									                 <input type="hidden" name="type" value="{$type}"/>
													 <input type="hidden" name="id" value="{$id}"/>
										<div id="js_edit_area" class="media_edit_area" style="margin-top: 0px;">
											<div class="js_edit_content portable_editor to_left appmsg_editor econtent1" style="display: block;"> 
							
												<div class="inner"> 
													<div class="editor_section"> 
														<h3 class="title"> 券面信息 </h3> 
														<div class="appmsg_edit_item"> 
															<label class="frm_label" for=""> <strong class="title">券面设计</strong> </label> 
															<div class="input_submsg"> 
																<div class="frm_controls frm_vertical_lh"> 
																	<div class="brand_item"> 
																		<div class="brand_img">
																	
																			<notempty name="data[imgurl]">
																			<img src="{$data[imgurl]}"  />
																			</notempty>
																		
																		</div>
																		<input type="hidden" name="thumb" id="cover_id_thumb"/>
										                          <input  type="file" id="upload_picture_thumb">   
										
								<script type="text/javascript">
								//上传图片
							    /* 初始化上传插件 */
								$("#upload_picture_thumb").uploadify({
							        "height"          : 30,
							        "swf"             : "/Public/static/uploadify/uploadify.swf",
							        "fileObjName"     : "download",
							        "buttonText"      : "上传劵面",
							         "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",					
							        "width"           : 120,
							        'removeTimeout'	  : 1,
							        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
							        "onUploadSuccess" : uploadPicturethumb,
							        'onFallback' : function() {
							            alert('未检测到兼容版本的Flash.');
							        }
							    });
								function uploadPicturethumb(file, data){ //alert(data);
							    	var data = $.parseJSON(data);
							    	var src = '';
							        if(data.status){
							        	
							        	src = data.url || '__ROOT__' + data.path
										$("#cover_id_thumb").val(src);
							        	$("#cover_id_thumb").parent().find('.brand_img').html(
							        		'<div class="upload-pre-item"><img src="' + src + '"/></div>'
							        	);
							        } else {
							        	alert(data.info);
							        	setTimeout(function(){
							                $('#top-alert').find('button').click();
							                $(that).removeClass('disabled').prop('disabled',false);
							            },1500);
							        }
							    }
								</script>
																	</div> 
																</div> 
															</div> 
															<p class="frm_tips">如不上传券面,默认使用标准样式</p> 
														</div> 
				
														 
			
			<if condition="$type eq 2 ">
												
														<div class="appmsg_edit_item"> 
															<label class="frm_label" for=""> <strong class="title">抵扣条件</strong> </label> 
															<div class="input_submsg"> 
																<span class="frm_input_box"> <input type="text" placeholder="" class="frm_input valid" name="jianmian" id="js_reduce_cost" value="{$data[jianmian]}" onkeyup="value=value.replace(/[^1234567890\.]+/g,'')"/> </span> 
																<span>元</span> 
															</div> 
															<p class="frm_tips">消费满多少元可用。如不填写则默认：消费满任意金额可用。只能是大于0.01的数字</p>
														</div> 
														<div class="appmsg_edit_item"> 
															<label class="frm_label" for=""> <strong class="title">减免金额</strong> <br /><p class="tips">(选填)</p> </label> 
															<div class="input_submsg group"> 
												<span class="frm_input_box"> <input type="text" placeholder="" class="frm_input" name="digggou"  value="{$data[dikou]}" onkeyup="value=value.replace(/[^1234567890\.]+/g,'')"/> </span> 
																<span>元</span> 
															</div> 
															<p class="frm_tips">减免金额只能是大于0.01的数字</p> 
														</div> 
<else />
														<div class="appmsg_edit_item"> 
															<label class="frm_label" for=""> <strong class="title">体验次数</strong> </label> 
															<div class="input_submsg"> 
																<span class="frm_input_box"> <input type="text" placeholder="" class="frm_input valid" name="times" id="js_reduce_cost" value="{$data[times]}"onkeyup="value=value.replace(/[^1234567890\.]+/g,'')"/> </span> 
																<span>次</span> 
															</div> 
															<p class="frm_tips">如不填写则默认1</p>
														</div> 
</if>
				
																<div class="appmsg_edit_item"> 
															<label class="frm_label" for=""> <strong class="title">库存</strong> </label> 
															<div class="input_submsg"> 
																<span class="frm_input_box"><input type="text" class="frm_input" value="{$data[total]}" name="total" onkeyup="value=value.replace(/[^1234567890]+/g,'')"/></span> 
																<span class="input_sub_msg">份</span> 
																<p class="frm_msg fail"><span for="quantity" class="frm_msg_content">库存只能是大于0的数字</span></p>
															</div> 
														</div> 
												
																							<div class="appmsg_edit_item appmsg_edit_item_label_mult appmsg_input_submsg_item group"> 
															<label class="frm_label l" for=""> <strong class="title">领券限制<br /><span class="tips">(选填)</span></strong> </label> 
															<div class="input_submsg l"> 
																<span class="frm_input_box"><input type="text" placeholder="" class="frm_input" value="{$data[get_limit]}" name="get_limit" onkeyup="value=value.replace(/[^1234567890]+/g,'')"/></span> 
																<span class="input_sub_msg">张</span> 
															</div> 
															<p class="frm_tips">每个用户领券上限，如不填，则默认为1</p> 
														</div> 
													<div class="appmsg_edit_item textarea_item"> 
														<label class="frm_label" for=""> <strong class="title">卡券描述</strong> </label> 
														<div class="frm_controls"> 
															<div class="frm_textarea_box"> 
																<textarea placeholder="卡券描述不能为空" name="title" class="frm_textarea" id="description">{$data[title]}</textarea> 
															</div> 
														</div> 
														<p class="frm_msg fail"><span for="description" class="frm_msg_content">卡券描述不能为空且长度不超过300个汉字</span></p>
													</div> 


														<div class="appmsg_edit_item radio_item"> 
															<div class="frm_control_group radio_row"> 
																<label class="frm_label" for="">有效期</label> 
																<div class="frm_controls frm_vertical_lh"> 
																	<div class="radio_control_group group"> 
																		<label class="frm_radio_label frm_radio_input selected" for="checkbox1"> <i class="icon_radio"></i><input type="radio" class="frm_radio js_validtime" value="1" id="checkbox1" checked="checked" /><span class="lbl_content"> 固定日期 &nbsp;&nbsp;</span> </label> 
																		<div id="ymdatepicker" class="input-daterange input-group">
																			<input type="text" value="{$data[starttime]}" name="starttime" class="input-sm form-control" id="ymstart" placeholder="有效开始时间">
																			<span class="input-group-addon"> T O </span>
																			<input type="text" value="{$data[endtime]}" name="endtime" class="input-sm form-control" id="ymend" placeholder="有效结束时间">
																		</div>
																	</div> 
																</div> 
															</div> 
														</div> 
													</div> 
												</div> 
												<i style="margin-top: 0px;" class="arrow arrow_out"></i> 
												<i style="margin-top: 0px;" class="arrow arrow_in"></i> 
											</div> 

										</div> 
								
								</div> 
								<div class="tool_bar border tc">
									<button    id="submit" type="submit" class="btn btn-primary ajax-post" target-form="form-horizontal" style="height: 36px;"> 提交卡券 </button>
								</div>	</form> 
							</div>
						</div>
                    </div>
                </div>
        	</div>
            <include file="Public/footer"/>
        </div>
	</div>
	<!-- DROPZddONE -->
   
    <script src="__JS__/icheck.min.js"></script>
    <script type="text/javascript">

        $(document).ready(function() { 
			$('#ymdatepicker input').datepicker({
                keyboardNavigation: false,
                forceParse: false,
				format: "yyyy-mm-dd",
                autoclose: true
            });


          $('.i-checks').iCheck({
               checkboxClass: 'icheckbox_square-green',
               radioClass: 'iradio_square-green',
           });


		});

		function cc(){
		      var times = $("input[name='total']").val();
			  if(times<1)
			   {
                 	swal({
        					  title: "创建失败",
        					  text: '请填写库存',
        					  type: "error"
    						}, function () {
        				
   						   });
						   return false;
			   }
			   		  var title = $("textarea[name='title']").val();    

			  if(title=='')
			   {
                 	swal({
        					  title: "创建失败",
        					  text: '请填卡券描述',
        					  type: "error"
    						}, function () {
        					  
   						   });
						   return false;
			   }

			   			   		  var starttime = $("input[name='starttime']").val(); 
								  var endtime = $("input[name='endtime']").val();    
			  if(starttime=='' || endtime=='')
			   {
                 	swal({
        					  title: "创建失败",
        					  text: '请设置卡券期限',
        					  type: "error"
    						}, function () {
        				
   						   });
						   	return false;
			   }


		   }


    </script>

</body>
</html>